package com.huawei123.hasee.cniao5store.adapter.section;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.huawei123.hasee.cniao5store.R;
import com.huawei123.hasee.cniao5store.bean.AppBean;
import com.huawei123.hasee.cniao5store.view.widget.DownloadProgressButton;
import com.zhxu.recyclerview.base.ViewHolder;
import com.zhxu.recyclerview.section.StatelessSection;

import java.util.List;

/**
 * 项目名称：Cniao5Store
 * 类描述：排行页内容填充
 * 创建人：luohao
 * 创建时间：2018/2/5 18:57
 * 修改人：luohao
 * 修改时间：2018/2/5 18:57
 * 修改备注：
 */

public class TopContactsSection extends StatelessSection {

    private List<AppBean> appBeanMap;
    private Context context;
    private String title;

    public TopContactsSection(Context context, String title, List<AppBean> appBeanMap) {
        super(R.layout.applistitem_titlecard, R.layout.applistitem_normal);
        this.context = context;
        this.title = title;
        this.appBeanMap = appBeanMap;

    }

    @Override
    public int getContentItemsTotal() {
        return appBeanMap.size();
    }

    @Override
    public ViewHolder getItemViewHolder(View view, int viewType) {
        return new ItemViewHolder(view);
    }

    @Override
    public void onBindItemViewHolder(ViewHolder holder, int position) {
        AppBean appBean = appBeanMap.get(position);
        holder.setText(R.id.mTV_appSerial,appBean.getAliasName());
        holder.setImageUrl(R.id.mIV_appicon,appBean.getIcon()) ;
        holder.setText(R.id.mTV_ItemTitle,appBean.getName()) ;
        holder.setText(R.id.mTV_ItemText_star,appBean.getSizeDesc()) ;
        holder.setText(R.id.mTV_memo,appBean.getMemo()) ;
    }

    @Override
    public ViewHolder getHeaderViewHolder(Context context, View view) {
        return new HeaderViewHolder(view);
    }

    @Override
    public void onBindHeaderViewHolder(ViewHolder holder) {
        super.onBindHeaderViewHolder(holder);
        holder.setText(R.id.mTV_ItemTitle,title);
    }

    class HeaderViewHolder extends ViewHolder {

        TextView mTV_ItemTitle;
        TextView mTV_downbtn;
        ImageView mIV_arrow_right;

        public HeaderViewHolder(View view) {
            super(context,view);
            mTV_ItemTitle = (TextView) view.findViewById(R.id.mTV_ItemTitle);
            mTV_downbtn = (TextView) view.findViewById(R.id.mTV_downbtn);
            mIV_arrow_right = (ImageView) view.findViewById(R.id.mIV_arrow_right);

        }
    }

    class ItemViewHolder extends ViewHolder {

        TextView mTV_appSerial;
        ImageView mIV_appicon;
        DownloadProgressButton mDPB_downbtn ;
        TextView mTV_ItemTitle;
        TextView mTV_ItemText_star;
        TextView mTV_memo ;

        public ItemViewHolder(View view) {
            super(context,view);
            mTV_appSerial = (TextView) view.findViewById(R.id.mTV_appSerial);
            mIV_appicon = (ImageView) view.findViewById(R.id.mIV_appicon);
            mDPB_downbtn = (DownloadProgressButton) view.findViewById(R.id.mDPB_downbtn);
            mTV_ItemTitle = (TextView) view.findViewById(R.id.mTV_ItemTitle);
            mTV_ItemText_star = (TextView) view.findViewById(R.id.mTV_ItemText_star);
            mTV_memo = (TextView) view.findViewById(R.id.mTV_memo);


        }
    }
}
